/**
 * @Company: 北京慧点科技有限公司 | www.smartdot.com.cn
 * @Copyright 1998-2020 © Smartdot Technologies Co., Ltd.
 */
package com.springlearn.zhoufei.other.spring.demo2;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Scope;
import org.springframework.context.support.AbstractApplicationContext;

@Configurable // 相当于Bean2.xml
public class HelloWorld10_1 {
    
    @Bean(initMethod = "init", destroyMethod = "destroy")
    @Scope("prototype")
    public HelloWorld10 HelloWorld10() {
        return new HelloWorld10();
    }
    
    public static void main(String[] args) {
        // 当实例化上下文时，不需要同时指定HelloWorld8_1.class和HelloWorld6_1.class，只有HelloWorld9类需要提供
        AbstractApplicationContext context = new AnnotationConfigApplicationContext(HelloWorld10_1.class);
        
        HelloWorld10 HelloWorld10 = context.getBean(HelloWorld10.class);
        System.out.println(HelloWorld10.toString());
        context.registerShutdownHook();
    }
}